package com.union.core.organization.service;

import java.util.ArrayList;
import java.util.List;


import org.apache.log4j.Logger;

import com.union.core.organization.dao.OrganizationManagerDao;
import com.union.core.organization.dao.OrganizationParamDao;
import com.union.core.organization.dao.impl.OrganizationManagerDaoImpl;
import com.union.core.organization.dao.impl.OrganizationParamDaoImpl;
import com.union.core.organization.model.OrganizationManager;
import com.union.core.organization.model.OrganizationParam;
import com.union.core.sys.service.SysLogsService;

public class OrganizationParamService{
	
	private static Logger log = Logger.getLogger(SysLogsService.class.getName());
	private OrganizationParamDao organizationParamDaoImpl;
	private OrganizationManagerDao organizationDaoImpl;
	public OrganizationParamService(){
		organizationParamDaoImpl = new OrganizationParamDaoImpl();
		organizationDaoImpl = new OrganizationManagerDaoImpl();
	}
	
	public OrganizationParam query(int organization_id){
		OrganizationParam param = organizationParamDaoImpl.query(organization_id);
		log.info("PLAT: 机构参数列表: organization_id="+organization_id);
		return param;
	}
	
	public List<OrganizationParam> queryList(int grade){
		List<OrganizationParam> ParamList = organizationParamDaoImpl.queryList(grade);
		log.info("PLAT: 机构参数列表: grade="+grade);
		return ParamList;
	}
	/**
	 * 添加机构参数
	 * @param param
	 * @return
	 */
	public void add(OrganizationParam param){
		organizationParamDaoImpl.add(param);
		log.info("PALT 添加机构参数: "+param.getOrganization_id()+","+param.getOrganization_name());
	}
	
	/**
	 *更改机构参数
	 * @param param
	 * @return
	 */
	public void edit(OrganizationParam param){
		organizationParamDaoImpl.edit(param);
		log.info("PALT 更改机构参数: "+param.getOrganization_id());
	}
	
	/**
	 * 删除机构参数
	 * @param organization_id
	 * @return
	 */
	public void delete(int organization_id){
		organizationParamDaoImpl.delete(organization_id);
		log.info("PALT 删除机构参数: organization_id="+organization_id);
	}
	public List<String> getOrgNameList(String idList){
		List<String> nameList=new ArrayList<String>();
		String aid[]=idList.split(",");
		for(String id : aid){
			if(!"".equals(id)){
				OrganizationManager org=organizationDaoImpl.query(Integer.parseInt(id));
				if(org!=null){
					String oname= org.getOrganization_name();
					nameList.add(oname);
				}
			}
		}
		return nameList; 
	}
}